package com.ruoyi.app.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 图片验证码常量
 */
public class CaptchaConstants {

    @AllArgsConstructor
    @Getter
    public enum TemplateEnum {
        /**
         * 用户注册验证码
         */
        REGISTER("captcha:register:", 5, "math"),
        /**
         * 用户登录验证码
         */
        LOGIN("captcha:login:", 5, "math"),
        NULL("", 5, ""),
        ;
        private String redisPrefix;
        private Integer effectiveMin;
        private String type;

        public static TemplateEnum match(String redisPrefix) {
            for (TemplateEnum one : TemplateEnum.values()) {
                if (one.getRedisPrefix().equalsIgnoreCase(redisPrefix)) {
                    return one;
                }
            }
            return TemplateEnum.NULL;
        }
    }
}
